﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Skin2D.Bone;
using Skin2D.Control.LogSystem;
using System.Windows.Forms;

namespace Skin2D.Control
{
    class MyApplication
    {
        public static CursorManager m_CursorManager;
        public static CtrBoneListTreeView m_BoneListTreeView;
        public static CtrPropertyGrid m_PropertyGrid;
        public static EventLog m_EventLog = new EventLog();
        public static Bone2D m_root;


        public static void AddBone()
        {
            Bone2D m_selected = m_BoneListTreeView.getSelected();
            TreeNode m_selectedNode = m_BoneListTreeView.getSelectedNode();

            if (m_selected == null)
                return;

            Bone2D new_bone = new Bone2D(m_selected);
            m_selected.AddChild(new_bone);
            new_bone.setTranslate(m_selected.Length, 0);
            new_bone.setRotate(0);

            m_BoneListTreeView.InitTreeNode(new_bone, m_selectedNode);

            EventLog.AddLogNewBone(m_selected, new_bone);
        }


        public static void RemoveBone()
        {
            Bone2D m_selected = m_BoneListTreeView.getSelected();
            TreeNode m_selectedNode = m_BoneListTreeView.getSelectedNode();

            if (m_selected == null)
                return;

            Bone2D parent = m_selected.Parent;
            int child_index = parent.RemoveChild(m_selected);

            EventLog.AddLogRemoveBone(parent, m_selected, child_index);

            m_BoneListTreeView.RemoveBone(parent, m_selected);

           
        }
    }
}
